home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
sos3-2.lha
/
src
/
knl
/
knl_ext.h
< prev
next >
Wrap
C/C++ Source or Header
|
1992-01-23
|
7KB
|
199 lines
/* --------------------------------------------------------------------------
* Copyright 1992 by Forschungszentrum Informatik (FZI)
*
* You can use and distribute this software under the terms of the licence
* you should have received along with this program.
* If not or if you want additional information, write to
* Forschungszentrum Informatik, "STONE", Haid-und-Neu-Strasse 10-14,
* D-7500 Karlsruhe 1, Germany.
* --------------------------------------------------------------------------
*/
#ifndef KNLEXTH
#define KNLEXTH 1
#include <string.h>
#include <libc.h>
#include "psm.h"
class sos_Object;
class sos_Object_Array;
// ***************************** sos_Short *********************************
typedef short sos_Short;
// ***************************** sos_Int *********************************
typedef int sos_Int;
#define INT_SIZE 4
inline void bcopy_from_sos_Int (void *i, void *c)
{ *(sos_Int *)c = *(sos_Int *)i; }
inline void bcopy_to_sos_Int (void *i, void *c)
{ *(sos_Int *)i = *(sos_Int *)c; }
sos_String make_string_from_sos_Int_object (sos_Object);
sos_Object make_sos_Int_object_from_string (sos_String);
// ***************************** sos_Char ********************************
typedef char sos_Char;
#define CHAR_SIZE 1
inline void bcopy_from_sos_Char (void *ch, void *c)
{ *(sos_Char*)c = *(sos_Char*)ch; }
inline void bcopy_to_sos_Char (void *ch, void *c)
{ *(sos_Char*)ch = *(sos_Char*)c; }
sos_String make_string_from_sos_Char_object (sos_Object);
sos_Object make_sos_Char_object_from_string (sos_String);
// ************************** sos_Pointer ****************************
typedef void *sos_Pointer;
#define POINTER_SIZE 4
inline void bcopy_from_sos_Pointer (void *p, void *c)
{ *(sos_Pointer *)c = *(sos_Pointer *)p; }
inline void bcopy_to_sos_Pointer (void *p, void *c)
{ *(sos_Pointer *)p = *(sos_Pointer *)c; }
sos_String make_string_from_sos_Pointer_object (sos_Object);
sos_Object make_sos_Pointer_object_from_string (sos_String);
// **************************** sos_Offset ********************************
// sos_Offset is declared in "psm.h"
#define SOS_OFFSET_SIZE 4
inline void bcopy_from_sos_Offset (void *o, void *c)
{ *(sos_Offset *)c = *(sos_Offset *)o; }
inline void bcopy_to_sos_Offset (void *o, void *c)
{ *(sos_Offset *)o = *(sos_Offset *)c; }
sos_String make_string_from_sos_Offset_object (sos_Object);
sos_Object make_sos_Offset_object_from_string (sos_String);
// *************************** sos_Container *****************************
// sos_Container is declared in "psm.h"
#define SOS_CONTAINER_SIZE 4
inline void bcopy_from_sos_Container (void *ct, void *c)
{ *(sos_Container *)c = *(sos_Container *)ct; }
inline void bcopy_to_sos_Container (void *ct, void *c)
{ *(sos_Container *)ct = *(sos_Container *)c; }
sos_String make_string_from_sos_Container_object (sos_Object);
sos_Object make_sos_Container_object_from_string (sos_String);
// **************************** sos_Cstring *******************************
typedef char *sos_Cstring;
#define SOS_STRING_SIZE 4
inline void bcopy_from_sos_Cstring (void *s, void *c)
{ *(sos_Cstring *)c = *(sos_Cstring *)s; }
inline void bcopy_to_sos_Cstring (void *s, void *c)
{ *(sos_Cstring *)s = *(sos_Cstring *)c; }
sos_String make_string_from_sos_Cstring_object (sos_Object);
sos_Object make_sos_Cstring_object_from_string (sos_String);
// ****************************** sos_Id **********************************
class sos_Id
{
sos_Container ct;
sos_Offset os;
public:
sos_Container container () { return ct; }
sos_Offset offset () { return os; }
static sos_Id make (sos_Container ct, sos_Offset os)
{ sos_Id id; id.ct=ct; id.os=os; return id;}
sos_Bool operator== (sos_Id id) { return (sos_Bool) (ct == id.ct && os == id.os);}
sos_Bool operator!= (sos_Id id) { return (sos_Bool) (ct != id.ct || os != id.os);}
sos_Id get_type_id ();
void set_type_id (sos_Id tp);
};
#define SOS_ID_SIZE 8
inline void bcopy_from_sos_Id (void *i, void *c)
{ *(sos_Id *)c = *(sos_Id *)i; }
inline void bcopy_to_sos_Id (void *i, void *c)
{ *(sos_Id *)i = *(sos_Id *)c; }
sos_String make_string_from_sos_Id_object (sos_Object);
sos_Object make_sos_Id_object_from_string (sos_String);
// *************************** sos_Typed_id *******************************
class sos_Type;
class sos_Typed_id
{ sos_Id id;
sos_Id tp;
public:
static sos_Typed_id make (sos_Id id, sos_Id tp)
{ sos_Typed_id tpid; tpid.id=id; tpid.tp=tp; return tpid;}
sos_Id get_id () { return id; }
sos_Id get_tp () { return tp; }
sos_Container container () { return id.container(); }
sos_Offset offset () { return id.offset(); }
sos_Bool operator== (sos_Typed_id &tpid)
{ return (sos_Bool) (id == tpid.id && tp == tpid.tp); }
sos_Bool operator!= (sos_Typed_id &tpid)
{ return (sos_Bool) (id != tpid.id || tp != tpid.tp); }
static sos_Typed_id allocate (sos_Type, sos_Container);
static sos_Typed_id allocate (sos_Type, sos_Container, sos_Int);
static sos_Typed_id make (sos_Id);
}; // ** sos_Typed_id **
#define SOS_TYPED_ID_SIZE 16
inline void bcopy_from_sos_Typed_id (void *tpid, void *c)
{ *(sos_Typed_id *)c = *(sos_Typed_id *)tpid; }
inline void bcopy_to_sos_Typed_id (void *tpid, void *c)
{ *(sos_Typed_id *)tpid = *(sos_Typed_id *)c; }
// *************************** sos_Root_class *****************************
class sos_Root_class
{
protected:
sos_Typed_id _tpid;
public:
sos_Typed_id typed_id() {return _tpid;}
sos_Container container() {return _tpid.container();}
sos_Offset offset() {return _tpid.offset();}
};
// ************************* local offset handling *************************
extern sos_Typed_id sos_make_local_typed_id (sos_Offset, sos_Container);
extern sos_Offset sos_local_offset (sos_Object, sos_Container);
// *********************** scalar object representation ********************
extern sos_Scalar_object sos_object_from_extern (void* addr,
void bcopy_from (void*,void*),
sos_Id tp);
extern void sos_extern_from_object (void* addr,
sos_Object o,
void bcopy_to (void*,void*),
sos_Id tp);
extern sos_Int sos_Int_from_enum (sos_Object,sos_Type);
extern sos_Scalar_object sos_enum_from_sos_Int (sos_Int,sos_Type);
// ************************** type representation **************************
extern sos_Type sos_type_object (sos_Id,sos_Id);
// *********************** Auxiliary Operations ***************************
extern sos_Object NO_OBJECT;
#endif